﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ClassLibrary;

namespace BinaryTreeTest
{
    class Program
    {
        static void Main(string[] args)
        {
            TestInsert();
        }

        public static void TestTree()
        {
            Tree<int> tree1 = new Tree<int>(10);
            tree1.Insert(10);
            tree1.Insert(20);
            tree1.Insert(-5);
            tree1.Insert(1);
            tree1.Insert(7);
            tree1.Insert(3);
            tree1.Insert(4);

            string sortData = tree1.WalkTree();
            Console.WriteLine("Sort Data Is: {0} ", sortData);
        }

        static void TestInsert()
        {
            Tree<char> charTree = null;
            InsertIntoTree(ref charTree,'m','x','o','v','a','l','t');
            string sortData = charTree.WalkTree();
            Console.WriteLine("sort data is: {0}",sortData);
        }

        public static void InsertIntoTree<TItem>(ref Tree<TItem> tree, params TItem[] data) where TItem :IComparable<TItem>
        {
            foreach (TItem item in data)
            {
                if (tree == null)
                {
                    tree = new Tree<TItem>(item);
                }
                else
                {
                    tree.Insert(item);
                }
            }
        }
    }
}
